import Taro, { Component } from '@tarojs/taro'
import PropsType from 'prop-types'
import classnames from 'classnames'
import { View, Text } from '@tarojs/components'
import { AtButton } from 'taro-ui'
import '../styles/logisticsinfo.scss'

export default class DLogisticsInfo extends Component {

    onHanldeFirst(e) {
        e.stopPropagation()
        this.props.onHanldeFirst && this.props.onHanldeFirst(...arguments)
    }

    onHanldeSecode(e) {
        e.stopPropagation()
        this.props.onHanldeSecode && this.props.onHanldeSecode()
    }
    onHandleDetail(e) {
        e.stopPropagation()
        this.props.onHandleDetail && this.props.onHandleDetail(...arguments)
    }
    render() {
        const { className, startplace, endplace, money, time, ago, firstText, secodeText } = this.props
        return (
            <View className={classnames("b_logisticsinfo", className)}>
                {
                    // list && list.map((item, i) => {
                    <View className='b_logisticsinfo__item' onClick={this.onHandleDetail.bind(this)}>
                        <View className='b_logisticsinfo__item_startplace'>
                            <Text className='b_logisticsinfo__title'>起发地址</Text>
                            <Text className='b_logisticsinfo__text'>{startplace}</Text>
                        </View>
                        <View className='b_logisticsinfo__item_endplace item_title'>
                            <View className='item_title__left'>
                                <Text className='b_logisticsinfo__title'>目的地址</Text>
                                <Text className='b_logisticsinfo__text'>{endplace}</Text>
                            </View>
                            <View className='item_title__right'>
                                <Text className='item_title__right_money'>￥{money}</Text>
                            </View>
                        </View>
                        <View className='b_logisticsinfo__item_time item_title'>
                            <View className='item_title__left'>
                                <Text className='b_logisticsinfo__title'>发车日期</Text>
                                <Text className='b_logisticsinfo__text'>{time}</Text>
                            </View>
                            <View className='item_title__right'>
                                <Text className='item_title__right_ago'>{ago}</Text>
                            </View>
                        </View>
                        <View className='item_title item_title__btn'>
                            <View className='item_title__btn_right'>
                                {
                                    firstText && <AtButton className='item_btn item_btn__default' onClick={this.onHanldeFirst.bind(this)}>{firstText}</AtButton>
                                }
                                {
                                    secodeText && <AtButton className='item_btn item_btn__default' onClick={this.onHanldeSecode.bind(this)}>{secodeText}</AtButton>
                                }
                            </View>
                        </View>
                    </View>
                    // })
                }
            </View>
        )
    }
}

DLogisticsInfo.defaultProps = {
    className: '',
    startplace: '', endplace: '', money: '', time: '', ago: '',
    firstText: '',
    secodeText: '',
    onHanldeFirst: () => { },
    onHanldeSecode: () => { },
    onHandleDetail: () => { }
}
DLogisticsInfo.PropsType = {
    className: PropsType.oneOfType[PropsType.string, PropsType.object],
    startplace: PropsType.string, endplace: PropsType.string, money: PropsType.string, time: PropsType.string, ago: PropsType.string,
    firstText: PropsType.string,
    secodeText: PropsType.string,
    onHanldeFirst: PropsType.func,
    onHanldeSecode: PropsType.func,
    onHandleDetail: PropsType.func
}
